#ifndef CommandProcessor_First
#define CommandProcessor_First
#ifdef __GNUG__
#pragma interface
#endif

#include "RefCounted.h"

class Command;
class ObjArray;
class Menu;

//---- CommandProcessor --------------------------------------------------------

class CommandProcessor : public RefCounted {
protected:
	int cap, changeCount;

	virtual void PerformNormalCommand(Command* cmd);
	virtual Command *GetAt(int i);
	virtual void FinishFrom(int n);
public:
	MetaDef(CommandProcessor);
	CommandProcessor();
	~CommandProcessor();
	bool Modified()
		{ return changeCount > 0; }
	int Size()
		{ return cap; }
	void PerformCommand(Command* cmd);
	void DoCreateMenu(Menu *menu);
	void DoSetupMenu(Menu *menu);
	void DoMenuCommand(int cmdId);
	void Finish();
};

//---- SingleCommandProcessor --------------------------------------------------

class SingleCommandProcessor : public CommandProcessor {
protected:
	Command *lastCmd;

	void PerformNormalCommand(Command* cmd);
	void FinishFrom(int n);
	Command *GetAt(int i);
public:
	MetaDef(SingleCommandProcessor);
	SingleCommandProcessor();
};

//---- UnboundedCommandProcessor -----------------------------------------------

class UnboundedCommandProcessor : public CommandProcessor {
protected:
	ObjArray *cmdHistory;

	~UnboundedCommandProcessor();
	Command *GetAt(int i);
	void PerformNormalCommand(Command* cmd);
	void FinishFrom(int n);
public:
	MetaDef(UnboundedCommandProcessor);
	UnboundedCommandProcessor();
};

//---- BoundedCommandProcessor -------------------------------------------------

class BoundedCommandProcessor : public CommandProcessor {
protected:
	Command **mem;
	int start, size;

	~BoundedCommandProcessor();
	Command *GetAt(int i);
	void PerformNormalCommand(Command* cmd);
	void FinishFrom(int n);
public:
	MetaDef(BoundedCommandProcessor);
	BoundedCommandProcessor(int s);
};

#endif

